package cn.tradewin.pmp.pages.test;


import java.util.List;

import org.apache.tapestry5.EventContext;
import org.apache.tapestry5.SelectModel;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.slf4j.Logger;

import cn.tradewin.pmp.persist.model.MDept;
import cn.tradewin.pmp.select.model.DeptSelectModel;
import cn.tradewin.pmp.services.DeptManageService;

public class Select1 {
	
	@Property
	private Integer deptNo;
	
	@Property
	private SelectModel deptModel;
	
	@Inject
	Logger log;
	
	@Inject
	private DeptManageService service;
	
	void onActivate(EventContext ctx) {
		if (ctx.getCount() > 0) {
			deptNo = ctx.get(Integer.class, 0);
		}
	}
	
	Integer onPassivate() {
		return deptNo;
	}
	
	@Log
	void onPrepareForRender() {
		List<MDept> depts = service.getAllDepts();
		deptModel = new DeptSelectModel(depts);
		
	}
	
	@Log
	void onValidateFromInputs() {
		
	}
	
	
	@Log
	void onSubmit() {
	}
	
	@Log
	void onSuccess() {
		log.debug("deptNo = " + deptNo);
	}
}
